package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

public class CollectionDemo1 {
    public static void main(String[] args) {
        //Collection c = new ArrayList();//List集合有序，元素可重复
        Collection c = new HashSet();//Set集合无序，不可重复
        c.add(1);//自动装箱，实际上是c.add(Integer.valueOf(1));
        c.add(2);
        c.add(3);
        c.add(4);
        c.add(5);
        boolean b = c.add(1);
        System.out.println("b的值:"+b);

        System.out.println("c:"+c);
        System.out.println("c的元素个数:"+c.size());
        System.out.println("c是否为空:"+c.isEmpty());
        c.clear();
        System.out.println("c是否为空:"+c.isEmpty());
    }
}
